package com.api.shopapi.mapper;

import com.api.shopapi.entity.EElderlyHelp;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface EElderlyHelpMapper {

    @Insert("insert into e_elderly_help (ElderlyHelpCode,ElderlyCode,ElderlyName,UserCode,VolunteerName,VolunteerPhone,VolunteerAddress,CreateTime,StaffCode,GovernmentCode) values " +
            "(#{elderlyHelp.ElderlyHelpCode},#{elderlyHelp.ElderlyCode},#{elderlyHelp.ElderlyName},#{elderlyHelp.UserCode},#{elderlyHelp.VolunteerName}," +
            "#{elderlyHelp.VolunteerPhone},#{elderlyHelp.VolunteerAddress},#{elderlyHelp.CreateTime},#{elderlyHelp.StaffCode},#{elderlyHelp.GovernmentCode})")
    int insert(@Param("elderlyHelp") EElderlyHelp elderlyHelp);

    @Update("update e_elderly_help set VolunteerName=#{elderlyHelp.VolunteerName},VolunteerPhone=#{elderlyHelp.VolunteerPhone}," +
            "VolunteerAddress=#{elderlyHelp.VolunteerAddress} where ElderlyHelpCode=#{elderlyHelp.ElderlyHelpCode}")
    int update(@Param("elderlyHelp") EElderlyHelp elderlyHelp);

    @Delete("delete from e_elderly_help where ElderlyHelpCode=#{elderlyHelpCode}")
    int delete(@Param("elderlyHelpCode") String elderlyHelpCode);

    @Select("select * from e_elderly_help where ElderlyHelpCode=#{elderlyHelpCode} limit 1")
    EElderlyHelp getByElderlyHelpCode(@Param("elderlyHelpCode") String elderlyHelpCode);

    @Select("select * from e_elderly_help where ElderlyCode=#{elderlyCode} order by CreateTime desc")
    List<EElderlyHelp> getListByElderlyCode(@Param("elderlyCode") String elderlyCode);




}
